package com.mini.spring;

import cn.hutool.core.collection.CollUtil;
import com.mini.spring.beanfactory.DefaultBeanFactory;
import com.mini.spring.data.Car;
import com.mini.spring.data.Person;

public class Test {
    public static void main(String[] args) {
        DefaultBeanFactory beanFactory = new DefaultBeanFactory();

        BeanDefinition beanDefinitionCar = new BeanDefinition();
        beanDefinitionCar.setName("car");
        beanDefinitionCar.setBeanClass(Car.class);
        beanDefinitionCar.setValues(CollUtil.newArrayList(new Kv("brand", "五菱宏光")));
        // 注册car示例
        beanFactory.register(beanDefinitionCar);

        BeanDefinition beanDefinitionPerson = new BeanDefinition();
        beanDefinitionPerson.setName("person");
        beanDefinitionPerson.setBeanClass(Person.class);
        beanDefinitionPerson.setValues(CollUtil.newArrayList(new Kv("name", "张三"),
                new Kv("age", 18),
                new Kv("car", new BeanReference("car"))));
        // 注册car示例
        beanFactory.register(beanDefinitionPerson);

        Object person = beanFactory.getBean("person");
        System.out.println(person);
    }
}
